#import "AppViewController.h"


@interface AppViewController () {

}

/**
 * Initialize class's private variables
 */
- (void)_init;
/**
 * Localize UI components
 */
- (void)_localize;
/**
 * Visualize all view's components
 */
- (void)_visualize;

///**
// * General display new view controller
// */
//- (void)_presentViewController:(UIViewController *)viewController
//                        option:(UIViewAnimationOptions)option
//                     animation:(void(^)(void))animations
//                    completion:(void(^)(BOOL finished))completion;
//
///**
// * General display dashboard subview controller
// */
//- (void)_switchToViewController:(UIViewController *)viewController
//                      direction:(NSUInteger)direction
//                      animation:(void(^)(void))animations
//                     completion:(void(^)(BOOL finished))completion;

@end


@implementation AppViewController


#pragma mark - Class's constructors
- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self _init];
    }
    return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self _init];
    }
    return self;
}


#pragma mark - Cleanup memory
- (void)dealloc {
    
    [super dealloc];
}


#pragma mark - View's lifecycle
- (void)viewDidLoad {
    [super viewDidLoad];
    [self _localize];
    [self _visualize];
}
- (void)viewDidUnload {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
    [super viewDidUnload];
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [kDirector setDelegate:self];
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
}


#pragma mark - View's memory handler
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


#pragma mark - View's orientation handler
// iOS6 Compatible
- (BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
    return (UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight);
}
// iOS5 Compatible (Backward compatible with old implementation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
	return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
}


#pragma mark - View's event handler
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
}

- (IBAction)keyPressed:(id)sender {
}


#pragma mark - Class's properties


#pragma mark - Class's public methods


#pragma mark - Class's private methods
- (void)_init {
}
- (void)_localize {
}
- (void)_visualize {
}

//- (void)_presentViewController:(UIViewController *)viewController
//                        option:(UIViewAnimationOptions)option
//                     animation:(void(^)(void))animations
//                    completion:(void(^)(BOOL finished))completion
//{
//    [viewController.view setFrame:_frame];
//    [self addChildViewController:viewController];
//    
//    __block UIViewController *controller = [viewController retain];
//    [self transitionFromViewController:_currentController toViewController:viewController duration:0.3f options:option
//                            animations:^{
//                                [self.view addSubview:controller.view];
//                                [_currentController.view removeFromSuperview];
//                                
//                                if (animations) animations();
//                            }
//                            completion:^(BOOL finished) {
//                                [controller didMoveToParentViewController:self];
//                                [_currentController removeFromParentViewController];
//                                
//                                _currentController = controller;
//                                safeRelease(controller);
//                                
//                                if (completion) completion(finished);
//                            }];
//}
//- (void)_switchToViewController:(UIViewController *)viewController
//                      direction:(NSUInteger)direction
//                      animation:(void(^)(void))animations
//                     completion:(void(^)(BOOL finished))completion
//{
//    [viewController.view setFrame:_frame];
//    [self.view addSubview:viewController.view];
//    [self addChildViewController:viewController];
//    
//    // Calculate position
//    CGPoint center  = _currentController.view.center;
//    CGPoint centerL = _currentController.view.center;
//    CGPoint centerR = _currentController.view.center;
//    centerL.x -= _frame.size.width;
//    centerR.x += _frame.size.width;
//    
//    // Prepare to animation
//    __block UIViewController *controller = [viewController retain];
//    
//    [self.view setUserInteractionEnabled:NO];
//    [controller.view setHidden:NO];
//    [controller.view setCenter:(direction == kDirectionLR ? centerL : centerR)];
//    [UIView animateWithDuration:0.3f delay:0.0f options:UIViewAnimationCurveEaseOut
//                     animations:^{
//                         [controller.view setCenter:center];
//                         [_currentController.view setCenter:(direction == kDirectionLR ? centerR : centerL)];
//                         
//                         if (animations) animations();
//                     }
//                     completion:^(BOOL finished) {
//                         [controller didMoveToParentViewController:self];
//                         
//                         [_currentController.view removeFromSuperview];
//                         [_currentController removeFromParentViewController];
//                         
//                         _currentController = controller;
//                         safeRelease(controller);
//                         
//                         [self.view setUserInteractionEnabled:YES];
//                         if (completion) completion(finished);
//                     }];
//}


#pragma mark - Class's notification handlers


@end
